package admin

import (
	"gin-demo/controllers"
	"gin-demo/pkg/e"
	"gin-demo/service"
	valid "gin-demo/validation"
	"github.com/gin-gonic/gin"
	"net/http"
)

type IndexController struct {
	controllers.BaseController
}

func (con IndexController) Index(c *gin.Context) {
	defer con.PanicHandler(http.StatusOK)
	con.C = c

	postData := new(valid.LoginCheck)
	con.ParseJson(c, &postData)

	errMsg := postData.ValidLogin()
	if errMsg != nil {
		con.ErrResponse(http.StatusOK, e.InvalidParams, errMsg.Error())
	}

	//eqString := mapper.BaseMapper{}.WhereEq(postData.Username, "username")

	service.UserService.UserLogin(postData.Username)

	con.Response(http.StatusOK, e.SUCCESS, nil)
}
